package com.example.module_motorcircle.motor_circle.repository

import com.example.lib_net.api.Api
import com.example.lib_net.model.api.BaseModel
import com.example.module_motorcircle.motor_circle.model.MotoCircleNavigationEnum
import com.example.module_motorcircle.motor_circle.model.MotorCircleNavigationItem
import com.example.module_motorcircle.post.model.CollectRequestModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import javax.inject.Inject

/**
 * @author yaotianxue
 * @description
 * @date 2025/2/11
 */
class MotorCircleRepository @Inject constructor() {
    @Inject
    lateinit var api:Api

    /**
     * 获得导航数据:本地数据
     */
    fun getNavigationItem() = flow {
        val baseModel = BaseModel(code = 0 , data = getMotorCircleNavigationItems(), msg = "", errorCode = -1)
        emit(baseModel)
    }.flowOn(Dispatchers.IO)


    //本地数据:来自数据库或者模拟
    private fun getMotorCircleNavigationItems():MutableList<MotorCircleNavigationItem>{
        val list = mutableListOf<MotorCircleNavigationItem>()
        val navList = listOf(
            MotoCircleNavigationEnum.HOT,
            MotoCircleNavigationEnum.TOPIC,
            MotoCircleNavigationEnum.INFORMATION,
            MotoCircleNavigationEnum.FOLLOW)
        navList.forEach {
            list.add(
                MotorCircleNavigationItem(
                modelList = null,
                navigationId = it.navId.toString(),
                type = it.type,
                title = it.title,
                sort = it.sort,
                value = it.name,
                status = 1
            )
            )
        }
        return list
    }


}